//
//  AXFHHeadView.m
//  AXFEightGroup
//
//  Created by hgj on 2016/12/22.
//  Copyright © 2016年 ya. All rights reserved.
//

#import "AXFHHeadView.h"

@implementation AXFHHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"v2_my_avatar_bg"]];
        [self addSubview:imageView];
        
        UIButton *button = [[UIButton alloc]init];
        [button setImage:[UIImage imageNamed:@"v2_my_settings_icon"] forState:UIControlStateNormal];
        if (_Block) {
            self.Block();
        }
        [button addTarget:self action:@selector(clickSetingButton:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
     
        UIImageView *headImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"v2_my_avatar"]];
        [headImageView sizeToFit];
        [self addSubview:headImageView];
        
        UILabel *phoneLabel = [[UILabel alloc]init];
        phoneLabel.text = @"15651796168";
        phoneLabel.font = [UIFont systemFontOfSize:20];
        phoneLabel.textColor = [UIColor whiteColor];
        phoneLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:phoneLabel];
        
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
        
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self).offset(-10);
            make.top.equalTo(self).offset(10);
            make.width.and.height.mas_equalTo(50);
        }];
        [headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self).offset(50);
        }];
        [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(headImageView.mas_bottom).offset(5);
            make.leading.trailing.equalTo(self);
            make.height.mas_equalTo(30);
        }];
    }
    return self;
}

- (void)clickSetingButton:(UIButton *)button {
    [self sendActionsForControlEvents:UIControlEventTouchUpInside];
}

@end
